package com.yk.airline.dao.origindata.impl;

import com.yk.airline.dao.common.impl.CommonDaoImpl;
import com.yk.airline.dao.origindata.api.IOriginDataDao;
import com.yk.airline.model.CaptureMarkModel;
import com.yk.airline.model.OriginDataModel;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Project Name:airlinecrawler
 * File Name:OriginDataDaoImpl
 * Package Name:com.yk.airline.dao.origindatadao.impl
 * Date:2018/1/31 14:36
 * Author:dengtianjia
 * Description:
 * Copyright (c) 2018, 重庆云凯科技有限公司 All Rights Reserved.
 */
@Repository("originDataDao")
public class OriginDataDaoImpl extends CommonDaoImpl<OriginDataModel> implements IOriginDataDao {

    @Override
    public List<OriginDataModel> findAll() {
        String hql = "from OriginDataModel";
        return super.comSearchDao.findByParams(hql,null);
    }

    @Override
    public int findTotalCount() {
        String hql  = "select count(*) from OriginDataModel";
        return super.comSearchDao.findCount(hql,null);
    }

    @Override
    public List<OriginDataModel> findByCaptureMark(CaptureMarkModel mark) {
        String hql = "from OriginDataModel o where o.captureMarkByCaptureMarkId.id = :id";
        Map<String,Object> params = new HashMap<>();
        params.put("id",mark.getId());
        return super.comSearchDao.findByParams(hql,params);
    }

}
